package com.ysg.widget.dialog.adapter;

import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ysg.R;
import com.ysg.http.data.entity.user.UserResult;
import com.ysg.utils.YImageUtil;

/**
 * 搭讪
 */
public class AccostAdapter extends BaseQuickAdapter<UserResult, BaseViewHolder> {
    public AccostAdapter() {
        super(R.layout.item_random_user);
    }

    @Override
    protected void convert(BaseViewHolder holder, UserResult item) {
        View parent = holder.getView(R.id.parent);
        ImageView ivAvatar = holder.getView(R.id.ivAvatar);
        TextView tvName = holder.getView(R.id.tvName);
        CheckBox checkBox = holder.getView(R.id.checkBox);

        tvName.setText(item.getNick());

        YImageUtil.show(ivAvatar, item.getPic());
        checkBox.setChecked(item.isChecked());
        parent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                item.setChecked(!item.isChecked());
                notifyDataSetChanged();
            }
        });

    }
}
